# -*- coding:utf-8 -*-
"""
@author:shengwei
@file:Write.py
@time:2018/2/12 001217:50
"""
from io import StringIO
import os
import pickle

class Write(object):
    def write_files(self):
        # try:
            # print(os.path.abspath('./'),os.path.join(r'F:\anaconda\www','666'),os.makedirs(r"F:\anaconda\www\666"))
            # d = [13,2,'dsa']
            # print(pickle.dump(d))
            # d = dict(name='Bob', age=20, score=88)
        obj = {"a": 1, "b": 2, "c": 3}

        # 将 obj 持久化保存到文件 tmp.txt 中
        pickle.dump(obj, open("test.txt", "w"))

        # do something else ...

        # 从 tmp.txt 中读取并恢复 obj 对象
        obj2 = pickle.load(open("test.txt", "r"))

        print(obj2)
            # f = StringIO()
            # f.write('oop,sw')
            # f = open('./test.txt', 'a', encoding='gbk', errors='ignore')
            # print(f.write('hello sw,'))
            # f.close()
        # except Exception as e:
        #     print('error----', e)


oop = Write()
oop.write_files()
# with open('./oop.txt','r') as f:
#     print(f.read())
